package com.tydic.common.web.utils;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;

import java.nio.charset.StandardCharsets;

public class AesUtils {
    //密钥 (需要前端和后端保持一致)
    public static final String KEY = "fee662c1f4d24308b5230b160268345e";

    private static AES createAES() {
        return new AES(Mode.ECB, Padding.PKCS5Padding, KEY.getBytes(StandardCharsets.UTF_8));
    }

    public static String encrypt(String data) {
        return createAES().encryptBase64(data);
    }

    public static String decrypt(String data) {
        return createAES().decryptStr(data);
    }
}
